home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 090 / jbl.arc / BOXDZINE.BAS < prev    next >
Encoding:
BASIC Source File  |  1985-12-12  |  10.4 KB  |  240 lines

  1. 10 'Box design program to calculate ideal box dimensions from a given volume.
  2. 20 'or volume from the largest dimension, based on the ideal shape of the box.
  3. 30 'The dimensional relationship provides the fewest redundant eigenmodes
  4. 40 'in the decay spectrum of an enclosure's internal sound wave reflections.
  5. 50 'Written by Drew Daniels, Applications Engineer, JBL Incorporated, 2/20/85
  6. 60 '
  7. 70 '
  8. 80 'variable definitions
  9. 85 '
  10. 90 '
  11. 100 LOG10=LOG(10)  'for use in log to base 10 calculations (logx=lnx/ln10)
  12. 110 PI=3.141592654#
  13. 120 '
  14. 130 '
  15. 140 KEY OFF : COLOR 15,1,5 : CLS
  16. 150 '
  17. 160 PRINT"                      Copyright (c) 1985 by Drew Daniels
  18. 170 PRINT"           BOX&PORT.BAS program to calculate dimensions and porting"
  19. 180 PRINT"                 for loudspeaker enclosures with ideal shapes."
  20. 190 PRINT : PRINT
  21. 200 PRINT "                    ENCLOSURE DIMENSION DESIGN SUBROUTINE"
  22. 210 PRINT : PRINT
  23. 220 PRINT "   [A] Find Dimensions from Volume           [D] Volume of Suggested Bracing"
  24. 230 PRINT "   [B] Find Volume from Largest Dimension    [E] Design Vent for Enclosure"
  25. 240 PRINT "   [C] Find Volume from Existing Dimensions      Enter your choice . . ."
  26. 250 A$=INPUT$(1)
  27. 260 IF A$="A" OR A$="a" THEN 310 ELSE 270
  28. 270 IF A$="B" OR A$="b" THEN 430 ELSE 280
  29. 280 IF A$="C" OR A$="c" THEN 530 ELSE 290
  30. 290 IF A$="D" OR A$="d" THEN 570 ELSE 300
  31. 300 IF A$="E" OR A$="e" THEN 970 ELSE 250
  32. 310 PRINT
  33. 320 INPUT "Enter desired box volume in cubic feet  ",CUFT
  34. 330 IF CUFT >.01 THEN GOTO 340
  35. 340 CUIN=CUFT*1728 : VTEMP=CUIN^.333333333#  'cube root
  36. 350 AAA=VTEMP*1.20125 : BBB=AAA*.816496581# : CCC=AAA*.707106781#  'constant
  37. 360 PRINT
  38. 370 PRINT"   DIMENSION      SIDE A               SIDE B               SIDE C"
  39. 380 PRINT"                 --------             --------             --------"
  40. 390 PRINT USING"    interior     ###.# inches         ###.# inches         ###.# inches";AAA, BBB, CCC
  41. 400 PRINT USING"    exterior     ###.# inches         ###.# inches         ###.# inches";AAA+1.5, BBB+1.5, CCC+1.5
  42. 410 PRINT
  43. 420 GOTO 220
  44. 430 PRINT : INPUT"What is the largest INTERNAL dimension of the box  ";AAA
  45. 440 PRINT
  46. 450 BBB = AAA * .816496581# : CCC = AAA * .707106781#
  47. 460 VOLUME = AAA * BBB * CCC / 1728
  48. 470 PRINT"   DIMENSION    SIDE A          SIDE B         SIDE C         VOLUME"
  49. 480 PRINT"                ------          ------         ------         ------"
  50. 490 PRINT USING"  interior       ##.#           ##.#           ##.#          ###.##";AAA    ,BBB, CCC, VOLUME
  51. 500 PRINT USING"  exterior       ##.#           ##.#           ##.#          ###.##";AAA+1.5, BBB+1.5, CCC+1.5
  52. 510 PRINT
  53. 520 GOTO 220
  54. 530 PRINT : INPUT"Enter the interior dimensions of your box, in inches, separated by commas.       ",A,B,C
  55. 540 D=A*B*C/1728
  56. 550 PRINT USING "The volume of your box is ##.## cubic feet.";D
  57. 560 GOTO 410
  58. 570 PRINT
  59. 580 INPUT "          Enter desired box volume in cubic feet  ",CUFT
  60. 590 IF CUFT=0 THEN CLS : GOTO 580
  61. 600 CUIN=CUFT*1728 : VTEMP=CUIN^.333333333#  'cube root
  62. 610 AAA=VTEMP*1.20125 : BBB=AAA*.816496581# : CCC=AAA*.707106781#  'constant
  63. 620 IF CUFT < 1 THEN 630 ELSE 640
  64. 630 CLS : GOTO 740
  65. 640 IF CUFT < 4 THEN 650 ELSE 660
  66. 650 CLS : GOTO 690
  67. 660 IF CUFT > 4 THEN 670
  68. 670 CLS : GOTO 730
  69. 675 '
  70. 680 '
  71. 690 BRACEVOLUME=(3*((AAA*2)+(CCC*4)))/1728 : PRINT : GOTO 700
  72. 700 PRINT "Smaller volumes are calculated using 1x3 pine cleats for bracing."
  73. 710 GOTO 820
  74. 720 BRACEVOLUME=(1.5*3.5*((AAA*2)+(CCC*4)))/1728 : GOTO 800
  75. 730 BRACEVOLUME=(1.5*3.5*((AAA*2)+(CCC*5)))/1728 : GOTO 800
  76. 740 PRINT
  77. 750 PRINT "Bracing is generally not needed in small enclosures made of dense"
  78. 760 PRINT "materials.  If bracing is desired, use 1-in by 3-in pine cleats and"
  79. 770 PRINT "calculate their volume by the formula 1 x 3 x length/1728 to find"
  80. 780 PRINT "the total displacement volume in cubic feet.
  81. 790 PRINT : GOTO 220
  82. 800 PRINT
  83. 810 PRINT "Larger volumes are calculated using two by four cleats for bracing."
  84. 820 PRINT
  85. 830 PRINT USING "          THE BRACING TAKES UP .## CUBIC FOOT OF BOX VOLUME.";BRACEVOLUME
  86. 840 PRINT
  87. 850 PRINT "Proper bracing consists of two pieces running from top to bottom on"
  88. 860 PRINT "the back of the box, and two pieces running from front to back on"
  89. 870 PRINT "each of the two sides of the box.  In larger boxes, another piece"
  90. 880 PRINT "should be run from front to back somewhere near the center of the"
  91. 890 PRINT "baffle and back panel of the box.  The bracing should be glued and"
  92. 900 PRINT "screwed down, on edge, to the panels it is stiffening.  In addition"
  93. 910 PRINT "the baffle cutout disc that is normally discarded, can be glued and"
  94. 920 PRINT "screwed down to one of the box panels for stiffening."
  95. 930 PRINT "Front-mounted JBL drivers displace the following volumes:"
  96. 940 PRINT "8in=.05 cu.ft., 10in=.1 cu.ft., 12in=.15 cu.ft., 15in=.2 cu.ft.,18in=.3 cu.ft."
  97. 950 PRINT
  98. 960 GOTO 220
  99. 970 CLS
  100. 974 '
  101. 975 '
  102. 980 '======= VENT DESIGN =======
  103. 990 '
  104. 1000 GOSUB 1160  'design data input
  105. 1010 GOSUB 2050  'minimum vent size calculations
  106. 1020 PRINT
  107. 1030 PRINT USING "                     Minimum Vent AREA is ###.# square inches";    SV.MIN
  108. 1040 SVMINDIAM = SQR(SV.MIN/PI)*2
  109. 1050 PRINT USING"               The DIAMETER of a tubular duct would be ##.# inches";SVMINDIAM
  110. 1060 PRINT USING "      Duct LENGTH is ###.# inches, tuning a ##.# cubic foot box to ###.# Hz";LV,VBV,FBV
  111. 1070 VVMIN=SV.MIN*LV : VVVMIN=VVMIN/1728
  112. 1080 PRINT USING "           The duct VOLUME is #,### cubic inches or #.## cubic feet.";VVMIN,VVVMIN
  113. 1090 PRINT
  114. 1100 PRINT "      >>> DUCT VOLUME MUST BE ADDED TO THE DESIRED ENCLOSURE VOLUME. <<<"
  115. 1110 PRINT
  116. 1120 PRINT
  117. 1130 GOTO 1320  'vent menu
  118. 1140 '
  119. 1150 '
  120. 1160 '======= INPUT VENT DESIGN DATA =======
  121. 1170 '
  122. 1180 CLS
  123. 1190 PRINT "                VENTED LOUDSPEAKER ENCLOSURE DUCT DESIGN SUBROUTINE"
  124. 1200 PRINT
  125. 1210 PRINT "                [ Type CTRL-C and then F2 to go back to main menu ]"
  126. 1220 PRINT : PRINT : PRINT
  127. 1230 INPUT "                    Box internal volume (Vb) in cubic feet";VBV
  128. 1240 IF VBV < .1 THEN 1230
  129. 1250 INPUT "                  Box helmholtz tuning frequency (Fb) in Hz";FBV
  130. 1260 IF FBV < .1 THEN 1250
  131. 1270 INPUT "               Driver displacement volume (Vd) in cubic inches";VDV
  132. 1280 IF VDV < .1 THEN 1270
  133. 1290 RETURN
  134. 1300 '
  135. 1310 '
  136. 1320 '======= VENT DESIGN MENU =======
  137. 1330 '
  138. 1340 LOCATE 20,45 : PRINT "          FUNCTION MENU"
  139. 1350 LOCATE 21,45 : PRINT " [A] Select Volume and Tuning"
  140. 1360 LOCATE 22,45 : PRINT " [B] Change Vent Area or Diameter"
  141. 1370 LOCATE 23,45 : PRINT " [C] Change Duct Length"
  142. 1380 LOCATE 24,45 : PRINT " [D] Design Box"
  143. 1390 LOCATE 24,45 : PRINT "     Enter your choice . . ."
  144. 1400 PRINT
  145. 1410 CHOICE$=INPUT$(1)
  146. 1420 IF CHOICE$="A" OR CHOICE$="a" THEN 970 ELSE 1430
  147. 1430 IF CHOICE$="B" OR CHOICE$="b" THEN 1480 ELSE 1440
  148. 1440 IF CHOICE$="C" OR CHOICE$="c" THEN 1830 ELSE 1450
  149. 1450 IF CHOICE$="D" OR CHOICE$="d" THEN 50 ELSE 1410
  150. 1460 '
  151. 1470 '
  152. 1480 '======= CHANGE VENT AREA, FIND DUCT LENGTH =======
  153. 1490 '
  154. 1500 IF SV.MIN=0 THEN GOSUB 1160 ELSE 1520  'input data if missing
  155. 1510 GOSUB 2050  'find minimum vent area
  156. 1520 CLS : PRINT : PRINT
  157. 1530 GOTO 1560
  158. 1540 PRINT "              Type 'A' to enter area, type 'D' to enter diameter."
  159. 1550 PRINT
  160. 1560 PRINT "                Are you entering vent area [A] or diameter [D]"
  161. 1570 CALC$=INPUT$(1) : PRINT TAB(40)CALC$
  162. 1580 IF CALC$="D" OR CALC$="d" THEN 1600 ELSE 1590
  163. 1590 IF CALC$="A" OR CALC$="a" THEN 1640 ELSE 1540
  164. 1600 INPUT "                 Vent diameter Dv in inches";SVDIAM : PRINT
  165. 1610 IF SVDIAM < 1 THEN 1600
  166. 1620 SV=PI*(SVDIAM/2)^2
  167. 1630 PRINT USING"             Vent AREA Sv is ###.# square inches";SV : GOTO 1680
  168. 1640 INPUT "            Vent area Sv in square inches";SV
  169. 1650 IF SV < 1 THEN 1640
  170. 1660 DV=SQR(SV/PI)*2
  171. 1670 PRINT USING"     The equivalent DIAMETER of this area is ###.# inches";DV
  172. 1680 IF SV<SV.MIN THEN GOSUB 2180  'for warning message
  173. 1690 LV=SV/SV.LV-.825*SQR(SV)
  174. 1700 CUIN=SV*LV
  175. 1710 CUFT=CUIN/1728
  176. 1720 PRINT
  177. 1730 PRINT USING"            Duct LENGTH is ###.# inches";LV
  178. 1740 PRINT USING"            Duct VOLUME is #,### cubic inches or #.## cubic feet.";CUIN,CUFT
  179. 1750 PRINT "           THIS VOLUME MUST BE ADDED TO THE DESIRED ENCLOSURE VOLUME."
  180. 1760 PRINT "             Helmholtz Frequency (Fb) =";FBV;"Hz"
  181. 1770 PRINT "             Box Volume (Fb) =";VBV;"cubic feet
  182. 1780 PRINT
  183. 1790 IF LV < .5 THEN 2300
  184. 1800 GOTO 1320
  185. 1810 '
  186. 1820 '
  187. 1830 '======= CHANGE DUCT LENGTH, FIND VENT AREA =======
  188. 1840 '
  189. 1850 IF SV.MIN=O THEN GOSUB 1160 ELSE 1870  'input data if missing
  190. 1860 GOSUB 2050  'find minimum vent area
  191. 1870 CLS : PRINT : PRINT : PRINT : PRINT
  192. 1880 GOTO 1900
  193. 1890 PRINT"        WARNING: DUCT LENGTH IS LESS THAN 3/4-INCH (BAFFLE THICKNESS)."
  194. 1900 INPUT "                       Duct LENGTH in inches";LV
  195. 1910 IF LV < .75 THEN 1890
  196. 1920 SV=((SV.LV*.825+SQR((SV.LV*.825)^2+4*SV.LV*LV))/2)^2
  197. 1930 PRINT USING"                       Vent AREA is ###.# square inches";SV
  198. 1940 VENTDIAM = SQR(SV/PI)*2
  199. 1950 PRINT USING"                       Vent DIAMETER is ##.# inches";VENTDIAM
  200. 1960 CUIN=SV*LV
  201. 1970 CUFT=CUIN/1728
  202. 1980 PRINT USING"             Duct VOLUME is #,### cubic inches or #.## cubic feet.";CUIN,CUFT
  203. 1990 IF SV<SV.MIN THEN GOSUB 2180  'for warning message
  204. 2000 PRINT "             Helmholtz Frequency (Fb) =";FBV;"Hz"
  205. 2010 PRINT "             Box Volume (Vb) =";VBV;"cubic feet"
  206. 2020 GOTO 1320
  207. 2030 '
  208. 2040 '
  209. 2050 '======= MINIMUM VENT SIZE CALCULATIONS =======
  210. 2060 '
  211. 2070 L=2350/(FBV^2*VBV)
  212. 2080 SV.MIN=8.25*VDV/(SQR(FBV))
  213. 2090 SV.LV=1728*VBV*(6.2832*FBV/13504)^2  'vent area-to-effective-length ratio
  214. 2100 LV=SV.MIN/SV.LV-.825*SQR(SV.MIN)
  215. 2110 IF LV<.75 THEN LV=.75
  216. 2120 SV.MIN=((SV.LV*.825+SQR((SV.LV*.825)^2+4*SV.LV*LV))/2)^2
  217. 2130 SVMINDIAM=SQR(SV.MIN/PI)*2
  218. 2140 LV=INT(LV*10^2+.5)/10^2
  219. 2150 RETURN
  220. 2160 '
  221. 2170 '
  222. 2180 '======= WARNING MESSAGE =======
  223. 2190 '
  224. 2200 COLOR 7
  225. 2210 PRINT USING " WARNING: this vent area is less than the desired minimum of ###.#";SV.MIN
  226. 2220 PRINT "  square inches as recommended in Small to keep air particle velocity
  227. 2230 PRINT "  in the vent below 2% of the speed of sound, for near-lossless 
  228. 2240 PRINT "  system tuning.  Acceptably good results can be obtained by using
  229. 2250 PRINT "  one port per driver whose diameter is AT LEAST 1/3 that of the 
  230. 2260 PRINT "  driver, or whose area is equal to a circle with that diameter.
  231. 2270 COLOR 15
  232. 2280 RETURN
  233. 2290 '
  234. 2300 PRINT "                      DESIGN ERROR - PROGRAM ABORTED"
  235. 2310 PRINT "                   Press F2 key to restart the program."
  236. 2320 STOP
  237. 2330 '
  238. 2340 '
  239. 2350 END
  240.